home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-09-08 | 6.1 KB | 123 lines | [TEXT/GEOL] |
- Item 8522730 7-Sept-89 19:30
-
- From: D1282 Power Up,PRT
-
- To: MACDTS Mac Developer Tech Support, APL
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: scaleable views
-
- Dear Keith,
-
- As I trust you recall, from our previous links, I've been attempting to
- implement scaleable views via GrafProcs in MacApp. It's all been going pretty
- well, but I have come across a few things that I need to know more about before
- I can proceed. So, batten down the hatches, and prepare to repel MacApp source
- questions.
-
- Background:
- • TView has been changed to have a fScaleFactor attribute, which can range
- from 1 to maxint, with the default setting being 100 (100% of normal). A view
- with a scaling factor of 200 draws at twice normal size (200% of normal), while
- a view with a scaling factor of 50 draws at half normal size (50% of normal).
- • A set of GrafProcs do all of the necessary scaling when drawing and
- printing. These GrafProcs are kept in a global variable, gScalingGrafProcs.
- • In TView.Focus(), a check is made to see if the view's fScaleFactor is
- 100. If so, GetWindow.grafProcs := NIL; else, GetWindow.grafProcs :=
- @gScalingGrafProcs. This is not strictly necessary, but there's no reason to
- suffer the overhead of the GrafProc calls when they're not needed.
- • The goal of the approach taken is to put all of the scaling code into
- MacApp, so that it is transparent to the application program. Thus, the
- application programmer never has to worry about which coördinate space she's
- in; she's always in scaled coördinates (what MacExpress calls 'pad
- coördinates').
- • Screen scaling has nothing to do with print reduction/enlargement. That
- is, a user could specify a scaling factor such that the contents of the view
- fit in the view's window (say, 27%), while having an enlargement of 200%
- specified in Page Setup. These two settings are entirely distinct.
- • I'm using the MacApp 2.0B9 example DrawShapes as my test program.
-
- Problem #1: Focusing in TApplication.TrackMouse()
- I'm having problems with TApplication.TrackMouse() and its whole calling chain.
- Somewhere in the bowels of these routines, gFocusedView is set to be the
- correct view WITHOUT calling Focus on it. I assume that this is being done for
- performance reasons. The result of this is that when creating new shapes or
- selecting existing ones, the rect drawn by TrackFeedback() is not being scaled
- properly, because the GrafProcs that do the scaling have not been brought in by
- Focus() — because Focus() was never called. I have kludged my way around this
- by leaving the GrafProcs installed all of the time, whatever the scaling
- factor. The kludge works, but I'm not fond of it, and I'd rather see Focus()
- called properly.
-
- Question #1:
- Where is gFocusedView getting diddled, why isn't Focus being called instead,
- and how can I call Focus instead of diddling gFocusedView?
-
-
- Problem #2: Move() and MoveTo()
- I don't know of any way to intercept calls to Move() and MoveTo() without
- patching them (a step I am loath to take). I need to intercept them, though,
- so that the application programmer can pass in scaled coördinates, but still
- move to the right place. My routine would then scale the arguments to global
- coördinates, and then call the standard Move() or MoveTo() routine. This is
- the approach I used with the GrafProcs, and it worked quite well, but there's
- no bottleneck for Move() or MoveTo().
-
- I see a number of possible solutions; I could…
- • patch Move() and MoveTo(). I hate patches. There has to be a better way.
- • require the application programmer to always map the arguments to Move()
- and MoveTo() before calling the routines. This requires no effort on my part
- (now), but it will waste lots of everyone else's time down the road.
- • write two new methods, MoveScaled() and MoveToScaled(), which the
- application programmer can use instead of Move() and MoveTo(). The new
- routines would accept scaled arguments, do the necessary mapping, and then call
- the standard routines. This requires that every MacApp programmer learn yet
- another two methods, and use them correctly.
- • write two new TView methods, Move() and MoveTo(), that get called — like
- magic! — instead of the ToolBox routines of the same name. I tried this, and
- although it compiled OK, it died a horrible screaming death when I tried to run
- the test program (no surprise there — I'm surprised it compiled!).
-
- Question #2:
- What should I do? I have implemented the MoveScaled() and MoveToScaled()
- routines, and they do the job (with the caveat noted in the next question), but
- I can't shake the thought that I'm missing something — that there's a better
- way of intercepting these calls. Any ideas?
-
-
- Problem #3: Printing Scaled Views
- I was pleased to see that scaled views printed properly (that is, at normal
- scale, whatever the screen scaling) without my having to give it a second
- thought. However, my fix of the MoveTo() problem came and bit me — it scaled
- the given coördinates when printing as well as when drawing to the screen (not
- good). Therefore, if I'm going to continue to use the MoveToScaled() solution
- to the MoveTo() problem (as outlined above), I must be able to tell whether or
- not I'm printing when MoveToScaled() is called — or I have to get around the
- problem some other way.
-
- Another way I was thinking of approaching this problem is as follows: since I'm
- already changing MacApp, I might as well diddle with its printing code too
- (famous last words, I'm sure). I could modify Print() to save each printed
- view's scaling factor before printing, and restore it again afterwards,
- meanwhile printing with a scaling factor of 100 (normal). This would solve all
- my problems (though it may create new ones).
-
- Question #3:
- How can I solve this problem? How can determine if I'm printing when
- MoveToScaled() is called? Alternatively, do the proposed changes to Print()
- seem reasonable, or fraught with peril?
-
-
- Thanks for your help!
-
-
- James Plamondon
- Software Engineer
- PowerUp! Software
- 2929 Campus Drive, Suite 300
- San Mateo, CA 94403
- (415) 345-5900 x351
- AppleLink: D1282
-
-